/**
 * @author zhoushengtao
 * @since 2012-8-29 上午11:08:53
 */

package com.stchou.superbrowser.ui.widget;

import com.stchou.superbrowser.activity.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

public class SuperEditText extends LinearLayout
{

    Context m_context;
    AttributeSet m_attributeSet;

    private EditText m_editText;
    private Button m_closeButton;

    /**
     * @param context
     * @param attrs
     */
    public SuperEditText(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        m_context = context;
        m_attributeSet = attrs;
        init();
    }

    private void init()
    {
        // 在构造函数中将Xml中定义的布局解析出来。
        LayoutInflater.from(m_context).inflate(R.layout.edittext_super, this, true);

        m_editText = (EditText)findViewById(R.id.super_edit);
        m_closeButton = (Button)findViewById(R.id.button_hide);
        m_closeButton.setOnClickListener(new OnClickListener()
        {
            public void onClick(View arg0)
            {
                m_editText.setText("");
            }
        });
    }

    public String getText()
    {
        return m_editText.getText() + "";
    }

    public void setText(String text)
    {
        m_editText.setText(text);
    }

    public EditText getEditText()
    {
        return m_editText;
    }

    public Button getCloseButton()
    {
        return m_closeButton;
    }

}
